Skip to content

Allow users to configure custom link component#563

Open
virginiacc wants to merge 6 commits into
mainfrom
vcc-link-context
Open

Allow users to configure custom link component#563
virginiacc wants to merge 6 commits into
mainfrom
vcc-link-context

Conversation

@virginiacc
Copy link
Copy Markdown
Contributor

@virginiacc virginiacc commented May 4, 2026

This PR adds the ability for users to globally configure the DSR to use their router's link component.

Changes

  • Adds DSR Context that accepts a LinkComponent value. Defaults to a BaseLink component that outputs an anchor element.
  • Updates Link component to output the LinkComponent value from the DSR context
  • Updates Breadcrumbs component to use Link instead of anchor element
  • Removes react-router dependency

Breaking changes

  • Updates Link, Header, SecondaryNav, and Breadcrumb components to use to prop instead of href for compatibility with external link components

How to test this PR

  1. Wrap app in DSR context provider and pass it a custom link component:
<YourRouterProvider>
  <DSRContext value={{LinkComponent: YourLinkComponent}} >
    // App code
  </DSRContext>
  1. Update instances of Link, Breadcrumbs, SecondaryNav, and Header to use to instead of href
  2. Check that the component passed in the context is output anywhere the Link component is used

To do

  • Add documentation

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 4, 2026

PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://cfpb.github.io/design-system-react/pr-previews/pr-563/

Built to branch gh-pages at 2026-05-06 16:58 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

Comment thread src/components/Link/link.test.tsx Outdated
Comment thread src/context/dsr-context.tsx Outdated
Comment thread src/context/dsr-context.tsx
Comment thread src/components/Breadcrumb/breadcrumb.tsx Outdated
Comment thread src/components/Link/base-link.tsx Outdated
Comment thread src/components/Link/link.test.tsx Outdated
Comment thread src/components/Link/link.test.tsx Outdated
Comment thread src/components/Link/link.tsx Outdated
Comment thread src/context/dsr-context.tsx
Comment thread src/context/dsr-context.tsx Outdated
Comment thread src/context/dsr-context.tsx Outdated
Comment thread src/context/dsr-context.tsx Outdated
virginiacc and others added 2 commits May 6, 2026 08:43
Co-authored-by: Richard Dinh <1038306+flacoman91@users.noreply.github.com>
@virginiacc virginiacc marked this pull request as ready for review May 6, 2026 17:03
@virginiacc virginiacc requested a review from flacoman91 May 6, 2026 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants